#!/usr/bin/python
import socket
import sys
host = sys.argv[1]

class par_net:
    	def __init__(self,info):
		self.info  = info
		self.right_ip = []
	def get_info(self):
		map((lambda x: self.right_ip.append(self.check_ip(x))),self.info)
	    	map(self.print_info,self.info)
	def check_ip(self,each_info):
		try:
			print each_info
			result = socket.gethostbyaddr(each_info[4][0])
			if result != None:
				return each_info
			else :
				return None
		except socket.herror ,e :
			print "can 't look up name: %s" %e
	def print_info(self,each_info):
	    	print "family : %s\nsock type : %s\nproto : %s\ncanon name : %s\nsock address : %s\n" %(each_info[0],each_info[1],each_info[2],each_info[3],each_info[4])
	

	
try:
        info = socket.getaddrinfo(host,None)
        # info = (family ,socktype , proto , canonname , sock address)
        #   	print "family : %s\nsock type : %s\nproto : %s\ncanon name : %s\nsock address : %s"%(info[0],info[1],info[2],info[3],info[4])
        #print info
        tool = par_net(info)
        tool.get_info()

except  socket.gaierror,e:
        print "some error : %s " %e



